/*==================================================
Project:       Targeting Social Programs
Authors:       Diether W. Beuermann
               Bridget Hoffmann        
               Marco Stampini 
               David L. Vargas
               Diego Vera-Cossio
----------------------------------------------------
Creation Date:    May 2023
Modification Date:   
Do-file version:    01
References:          
Output:             
==================================================*/

/*==================================================
            0: Program set up
==================================================*/
*Written on STATA 17
drop _all
set varabbrev off	// no variable abbreviations allowed (personal preference)

** source dir
cd "${dir5r}" // graph dir

/*==================================================
            1: load and transformations
==================================================*/

*----------  1.1. Data prep:
use "${dir3r}/03_auxiliar/Budget_estimates.dta", clear

/*==================================================
            4: Make graphs 
==================================================*/

// CRRA 
#delimit ;
tw (connected crra year if type_m ==  "Baseline", 
        mcolor(red%80) msym(S) lcolor(red%80))
        (rcap crra_uci crra_lci year if type_m ==  "Baseline", 
            lcolor(red%80))
    (connected crra year if type_m ==  "Updated", 
        mcolor(ltblue%80) msym(0) lpattern(-) lcolor(ltblue%80) )
            (rcap crra_uci crra_lci year if type_m ==  "Updated", 
        lcolor(ltblue%80) )	
    (connected crra year if type_m ==  "Expanded", 
        mcolor(gray%80) msym(T) lcolor(gray%80))
    (rcap crra_uci crra_lci year if type_m ==  "Expanded", 
        lcolor(gray%80))
    (connected crra year if model_n ==  4 & type_m ==  "Dynamic", 
        mcolor(black%80) msym(D) lcolor(black%80))
                (rcap crra_uci crra_lci year if model_n ==  4 & type_m ==  "Dynamic", 
        lcolor(black%80)),
    legend(order(1 "Benchmark PMT"		 			
                3 "Updated PMT - Assets" 					
                5 "Expanded Coverage"	
                7 "Dynamic" ) pos(6) row(2)) 
    ytitle("Social Welfare (CRRA: {&rho} = 3)")
    xtitle("Year")
    xlabel(2019(1)2021)
    name(A, replace)
;
#delimit cr
graph export "F7_Performance_a_gainloss_ols_flexbudget_bst.png", as(png) replace width(1200)
graph export "F7_Performance_a_gainloss_ols_flexbudget_bst.pdf", as(pdf) replace 

// Budget
    #delimit ;
tw (connected budget_nat year if type_m ==  "Baseline", 
        mcolor(red%80) msym(S) lcolor(red%80))
        (rcap budget_nat_uci budget_nat_lci year if type_m ==  "Baseline", 
            lcolor(red%80))
    (connected budget_nat year if type_m ==  "Updated", 
        mcolor(ltblue%80) msym(0) lpattern(-) lcolor(ltblue%80) )
            (rcap budget_nat_uci budget_nat_lci year if type_m ==  "Updated", 
        lcolor(ltblue%80) )	
    (connected budget_nat year if type_m ==  "Expanded", 
        mcolor(gray%80) msym(T) lcolor(gray%80))
    (rcap budget_nat_uci budget_nat_lci year if type_m ==  "Expanded", 
        lcolor(gray%80))
    (connected budget_nat year if model_n ==  4 & type_m ==  "Dynamic", 
        mcolor(black%80) msym(D) lcolor(black%80))
                (rcap budget_nat_uci budget_nat_lci year if model_n ==  4 & type_m ==  "Dynamic", 
        lcolor(black%80)),
    legend(order(1 "Benchmark PMT"		 			
                3 "Updated PMT - Assets" 					
                5 "Expanded Coverage"	
                7 "Dynamic" ) pos(6) row(2))        
    ytitle("Program Budget" "Annual USD Millions PPP")
    xtitle("Year")
    xlabel(2019(1)2021)
    name(D, replace)
;
#delimit cr
graph export "F7_Performance_b_gainloss_ols_flexbudget_bst.png", as(png) replace width(1200)
graph export "F7_Performance_b_gainloss_ols_flexbudget_bst.pdf", as(pdf) replace 

